﻿using System;
using System.IO;
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SetVersionNumberTests.FileWriters {

	/// <summary>
	/// Some handy helper methods
	/// </summary>
	internal static class HelperClass {

		/// <summary>
		/// Attempts to load the embedded resource with the given name.
		/// </summary>
		/// <param name="resourceName">The name of the embedded resource to load</param>
		/// <returns>
		/// The contents of the embedded resource
		/// </returns>
		internal static string GetEmbeddedResource( string resourceName ) {
			using( var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName) ) {
				if( stream==null )
					Assert.Fail("Failed to get embedded resource:" + resourceName);
				var reader = new StreamReader(stream);
				var result = reader.ReadToEnd();
				return result;
			}//using
		}

	}//class

}//namespace
